<template>
	<div>
		<div class="weui-cells weui-cells_form" style="margin-top: 0;">
			<div class="weui-cell">
				<div class="weui-cell__hd"><label class="weui-label">账号</label></div>
				<div class="weui-cell__bd">
					<input class="weui-input accountNumber" type="text" v-model="userName" placeholder="请输入账号">
				</div>
			</div>
			<div class="weui-cell ">
				<div class="weui-cell__hd">
					<label class="weui-label">密码</label>
				</div>
				<div class="weui-cell__bd">
					<input class="weui-input passWord" type="password" v-model="passWord" placeholder="请输入密码">
				</div>
			</div>
		</div>
		<div class="forgetPassword">
			<router-link to='/forgetPassword'>忘记密码</router-link>
		</div>
		<div class="demos-content-padded" style="padding: 0.3rem 1.1rem;">
			<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary Login" @click="sibmit" style="float: right;margin-top: 0;background: #28c81e;width: 100%;">登录</a>
		</div>
	</div>
</template>

<script>
	import { TopTips,Toast } from 'we-vue';
	import { login } from '../../config/api';
	import { mapMutations } from 'vuex';
	export default {
		data() {
			return {
				userName:null,  //账号
				passWord:null   //密码
			}
		},
		mounted() {

		},
		computed: {
			
		},
		methods: {
			...mapMutations([
			    'RECORD_USERINFO',
			]),
			sibmit() {
				let accountNumber = this.userName
				let passWord = this.passWord
				if(!accountNumber || accountNumber==null){
					TopTips({message: '账号不能为空',duration: 1200})
				}else if(!passWord || passWord==null){
					TopTips({message: '密码不能为空',duration: 1200})
				}else{
					login(accountNumber,passWord).then(res=>{		
						if(res.code==100){
							this.RECORD_USERINFO(res.content)
							this.$router.push('home')
						}else{
							Toast.text(res.content)
						}						
					})
				}
			}
		},
	}
</script>

<style scoped="scoped" lang="less">
	
</style>
